//
//  TTNavigationViewController.m
//  TTBaseProject
//
//  Created by shny588 on 16/7/13.
//  Copyright © 2016年 tt. All rights reserved.
//

#import "TTNavigationViewController.h"

@interface TTNavigationViewController ()

@end

@implementation TTNavigationViewController

#pragma mark - life cycle
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //Custom initialization
        //标题样式
        NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                                   [UIColor blackColor],NSForegroundColorAttributeName,
                                                   [UIFont systemFontOfSize:18.0f],NSFontAttributeName,nil];
        [[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //nav的背景颜色
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    //去黑线
    [self.navigationBar setShadowImage:[[UIImage alloc] init]];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - private methods
// 得到之前VC的标题
- (NSString *)getFrontViewControllerTitle {
    NSInteger index = self.viewControllers.count - 2;
    if (index >= 0) {
        UIViewController *viewController = self.viewControllers[index];
        if (viewController.title) {
            return viewController.title;
        }else if (viewController.navigationItem.title)
        {
            return viewController.navigationItem.title;
        }
    }
    return @"返回";
}

@end
